<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<title>Search Zipcodes</title>
</head>	    
<body>

	<label for="city">City:</label>
    	<input id="city" type="text" name="city" minlength="2"/>
		
	<label for="state">State:</label>
		<input id="state" type="text" name="state" minlength="2" />
        
    <label for="zipcode">Zip code:</label>
    	<input id="zipcode" type="text" name="zipcode"/>
    
    <script type="text/javascript">
		$(function(){
			
			$.get('../api/zipcodes.php','json');
			
			$(".city").live('click',function(){
				var input = $(this).val();
				if(input.length() >= 2){
					$.post('find_zip.php', {_method: 'POST', input: input}, function(data){
						$("zipcode").val(data.zipcode);
					},'json');
					return false;
				}
			});
		});
	</script>    
        	
</body>
</html>